package com.salton123.arch.view

import android.view.View
import androidx.annotation.DrawableRes
import androidx.annotation.IntDef
import com.salton123.ui.base.BaseActivity
import com.salton123.ui.base.BaseDialogFragment
import com.salton123.ui.base.BaseFragment

/**
 * User: 巫金生(newSalton@outlook.com)
 * Date: 2017/7/12 15:22
 * Time: 15:22
 * Description:
 */
interface ITitleBarView {
    fun enableTitleBar(): Boolean {
        return true
    }

    @TitleBarStyle
    fun getRightStyle(): Int = TitleBarStyle.HIDDEN

    fun getRightText(): String = ""

    @DrawableRes
    fun getRightIcon(): Int? = null
    fun onRightClick(v: View?) {}

    @TitleBarStyle
    fun getLeftStyle(): Int = TitleBarStyle.ICON_TEXT

    fun getLeftText(): String = "返回"

    @DrawableRes
    fun getLeftIcon(): Int? = null

    fun onLeftClick(v: View?) {
        if (this is BaseActivity) {
            this.onBackPressedSupport()
        } else if (this is BaseFragment) {
            val comsume = this.onBackPressedSupport()
            if (!comsume) {
                this.activity().finish()
            }
        } else if (this is BaseDialogFragment) {
            this.dismissAllowingStateLoss()
        }
    }

    fun getTitleText(): String {
        return ""
    }
}

